//加密token
import { Base64 } from '../node_modules/js-base64/base64.min.js';

//获取token
function getToken() {
	let token = ''
	 uni.getStorage({
		key: 'token',
		success: function(res) {
			token= res.data
		}
	})
	let base64_token = Base64.encode(token)
	return 'Basic ' + base64_token
	return token
}
//封装请求
export default (url, data = {}, method = 'GET') => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: 'https://meituan.thexxdd.cn/api/' + url,
			data,
			method,
			header: {
				Authorization:getToken()
			},
			success(res) {
				if(res.statusCode == 200){
					resolve(res.data)
				}else if(res.statusCode == 401){
					console.log('没有权限')
				}
			},
			fail(err) {
				reject(err)
			}
		})
	})
}
